<!--  -->
<template>
<div class='innexForm'>
  <el-form :model="formData"
            ref="formData"
            label-width="120px"
            :disabled="true"
            size="mini">
    <el-form-item label="上报人" prop="userName">
      <el-input v-model="formData.userName" autocomplete="off" placeholder="暂无内容"></el-input>
    </el-form-item>
    <el-form-item label="上报人电话" prop="reportPhone">
      <el-input v-model="formData.reportPhone" autocomplete="off" placeholder="暂无内容"></el-input>
    </el-form-item>
    <el-form-item label="上报时间" prop="reportTime">
      <el-date-picker
        v-model="formData.reportTime"
        type="datetime"
        value-format="timestamp"
        default-time="12:00:00"
        :picker-options="dataPickerBeforeTodayOptions"
        placeholder="暂无内容">
      </el-date-picker>
    </el-form-item>
    <el-form-item label="日志分类" prop="logCategory">
      <el-select filterable v-model="formData.logCategory" placeholder="暂无内容">
        <el-option v-for="item in dictData.logType" :key="item.valueCode" :label="item.valueName" :value="item.valueCode"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="经纬度"
                prop="longitude">
      <el-col :span="11">
        <el-input v-model="formData.longitude"
                  :disabled="true"
                  placeholder="经度"></el-input>
      </el-col>
      <el-col :span="2"
              style="text-align: center">-</el-col>
      <el-col :span="11">
        <el-input v-model="formData.latitude"
                  :disabled="true"
                  placeholder="纬度"></el-input>
      </el-col>
    </el-form-item>
    <el-form-item label="发生地点" prop="happenAddress">
      <el-input v-model="formData.happenAddress" autocomplete="off" placeholder="暂无内容"></el-input>
    </el-form-item>
    <el-form-item label="事件描述" prop="description">
      <el-input v-model="formData.description" autocomplete="off" placeholder="暂无内容"></el-input>
    </el-form-item>
    <el-form-item label="图片" >
      <app-upload ref="appUpload" v-model="formData.pictureArr" ></app-upload>
    </el-form-item>
  </el-form>
</div>
</template>

<script>
// 这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
// 例如：import 《组件名称》 from '《组件路径》';
import { getUserGridTree } from '@/utils/SessionDataUtil'
import AppUpload from '@/components/AppMultiUpload'
import {getFolkLog} from '@/http/WangGeGuanLiApi'
import {getLogCategory} from '@/data/DictData'
export default {
// import引入的组件需要注入到对象中才能使用
  name: 'PeopleLogForm',
  props: {
    detailForm: {
      type: Object,
      default: function () {
        return {
        }
      }
    }
  },
  components: {AppUpload},
  data () {
    // 这里存放数据
    return {
      formData: {},
      queryData: {},
      dictData: {},
      treeData: [],
      treeOption: [],
      caseLevelOption: [],
      caseTypeOption: [],
      gridIdProps: {
        label: 'name',
        value: 'id'
      },
      dataPickerBeforeTodayOptions: {
        disabledDate (time) {
          return time.getTime() > Date.now()
        }
      }
    }
  },
  // 方法集合
  methods: {
    getTreeData () {
      let gridTree = getUserGridTree()
      if (gridTree && gridTree instanceof Array) {
        this.treeData = gridTree
        this.treeOption = gridTree
      }
    },
    getDetail (data) {
      getFolkLog(data.id).then(resp => {
        if (resp.code && resp.code === '200') {
          let data = resp.data
          this.formData = data
        }
      })
    }
  },
  // 监听属性 类似于data概念
  computed: {},
  // 监控data中的数据变化
  watch: {
    detailForm: {
      handler: function (data) {
        this.formData = JSON.parse(JSON.stringify(data))
        this.getDetail(this.formData)
      },
      deep: true,
      immediate: true
    }
  },
  // 生命周期 - 创建完成（可以访问当前this实例）
  created () {

  },
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted () {
    this.dictData.logType = getLogCategory()
  },
  beforeCreate () {}, // 生命周期 - 创建之前
  beforeMount () {}, // 生命周期 - 挂载之前
  beforeUpdate () {}, // 生命周期 - 更新之前
  updated () {}, // 生命周期 - 更新之后
  beforeDestroy () {}, // 生命周期 - 销毁之前
  destroyed () {}, // 生命周期 - 销毁完成
  activated () {} // 如果页面有keep-alive缓存功能，这个函数会触发
}
</script>
<style scoped>

</style>
